<?php

/**
 *    发起招标控制器
 *
 *    @author    Garbin
 *    @usage    none
 */
class Buyer_ogps_addofferprojectApp extends MemberbaseApp
{
     var $_ogps_addoffer_mod;

    function __construct()
    {
        $this->Buyer_ogps_addofferprojectApp();
    }
    function Buyer_ogps_addofferprojectApp()
    {
        parent::__construct();


    }
    //添加采购项目信息。采购项目信息列表
    function index()
    {
        /* 当前位置 */
        $this->_curlocal(LANG::get('member_center'), 'index.php?app=member',
                         LANG::get('my_ogps_addoffer'), 'index.php?app=buyer_ogps_addofferproject',
                         LANG::get('my_ogps_addoffer'));

        /* 当前用户中心菜单 */
        $this->_curitem('my_ogps_addoffer');
        $this->_config_seo('title', Lang::get('my_ogps_addoffer') . ' - ' . Lang::get('my_ogps_addoffer'));
        
         if (!IS_POST)
        {
            $page = $this->_get_page(10);
            $ogps_listoffer_mod = &m('ogps_offerproject');
            $offers = $ogps_listoffer_mod->findAll(array(
                'conditions'    => "ecmall_user_id=" . $this->visitor->get('user_id') . "{$conditions}",
                'fields'        => 'this.*',
                'count'         => true,
                'limit'         => $page['limit'],
                'order'         => 'offerproject_id DESC',
                
            ));
            $page['item_count'] = $ogps_listoffer_mod->getCount();

            $this->assign('offers', $offers);
            $this->_format_page($page);
            $this->assign('page_info', $page);
              /* 招标信息 */
             $this->display('buyer_ogps_addofferproject.index.html');
            
        }else{
            $data=array(
                'ecmall_user_id'=>$this->visitor->get('user_id'),
                'offerproject_name'=>$_POST['offerproject_name'],
                'offerproject_explanation' =>$_POST['offerproject_explanation'],
                'creationdate'=>date("Y-m-d H:i:s"),
                'modificationdate'=>date("Y-m-d H:i:s"),
             );
            
            $ogps_addoffer_mod = &m('ogps_offerproject');
            $offerproject_id=$ogps_addoffer_mod->add($data);
            $this->_error($ogps_addoffer_mod->get_error());
           
            if ($this->has_error())
            {
                $this->show_warning($this->get_error());
                return;
            }
            
            header("location:index.php?app=buyer_ogps_addofferproject&act=addpackage&offerproject_id=".$offerproject_id);
        }

    }
    
  //添加项目包信息  
    function addpackage()
    {       
         /* 当前位置 */
        $this->_curlocal(LANG::get('member_center'), 'index.php?app=member',
                         LANG::get('my_ogps_addoffer'), 'index.php?app=buyer_ogps_addofferproject',
                         LANG::get('my_ogps_addoffer'));

        /* 当前用户中心菜单 */
        $this->_curitem('my_ogps_addoffer');
        $this->_config_seo('title', Lang::get('my_ogps_addoffer') . ' - ' . Lang::get('my_ogps_addoffer'));
 
        if (!IS_POST)
        {
            
            $ogps_packager_mod = &m('ogps_package');
            $packages = $ogps_packager_mod->findAll(array(
                'conditions'    => "offerproject_id=" . $_GET['offerproject_id'] . "{$conditions}",
                'fields'        => 'this.*',
                'count'         => true,
                'limit'         => $page['limit'],
                'order'         => 'package_id DESC',
                
            ));

            $this->assign('packages', $packages);
            
            
            /* 招标信息 */
            $this->display('buyer_ogps_addofferproject.addpackage.html');

        }else{
                $ogps_addpackage_mod = &m('ogps_package');
                $ogps_addpackage_mod->add(array(
                    'offerproject_id'=>$_GET['offerproject_id'],
                    'package_name' => $_POST['package_name'],
                    'package_budget'=>$_POST['package_budget'],
                    'package_explanation' =>$_POST['package_explanation'],
                    'bid_id'=>  Ogps_packageModel::BID_ID_DEFAULT,
                ));

            if ($ogps_addpackage_mod->has_error())
            {
                $this->show_warning($ogps_addpackage_mod->get_error());
                return;
            }
            header("location:index.php?app=buyer_ogps_addofferproject&act=addpackage&offerproject_id=".$_GET['offerproject_id']);
        }
    }
    
    function eidtofferproject()
    {
        echo 'edit';
    }
    
}

?>
